import { Compiler } from "webpack";
import devConfig from "../configs/webpack.dev";
import WebpackDevMiddleware from "webpack-dev-middleware";
import WebpackHotMiddleware from "webpack-hot-middleware";
export default function webpackMiddleware(complier: Compiler) {
  const publicPath = devConfig.output!.publicPath!;

  const devMiddlewareOptions: WebpackDevMiddleware.Options = {
    publicPath,
    stats: "minimal",
    logLevel: "error",
  };

  return [
    WebpackDevMiddleware(complier, devMiddlewareOptions),
    WebpackHotMiddleware(complier),
  ];
}
